<template >
    <div>
        <van-card
        v-for="(item,index) in $store.state.good" :key="index"
  num="2"
  :price="item.price"
  
  :title="item.title"
  :thumb="item.pic"
>
        <template #thumb>
            <van-checkbox v-model="item.checked" checked-color="#ee0a24"></van-checkbox>
            <van-image :src="item.pic"></van-image>
        </template>
        <template #num>
            <van-stepper v-model="item.num" theme="round" button-size="22" disable-input />
        </template>
</van-card>
<van-submit-bar :price="total" button-text="提交订单" >
    <van-checkbox v-model="checked" checked-color="#ee0a24" @change="check"></van-checkbox>
</van-submit-bar>
    </div>
</template>
<script>
export default {
        data(){
            return{
                checked:false,
                
            }
        },
        methods:{
           
            fx(){
      let tmp = this.$store.state.shifts.filter(res=>{
        console.log(res);
        return  res.checked == true;
      })
      if (tmp.length == this.$store.state.shifts.length) {
          this.checked = true;
      } else {
          this.checked = false;
      }
     },
     check(){
       this.$store.state.shifts.map(item=>{
         return item.checked = this.checked;
       })
     }

        },
        computed:{
            total(){
        let ntm = 0;
        // 计算数据 遍历每一条数据 
        this.$store.state.good.forEach(item => {
         
            if (item.checked == true) {
                ntm += item.num*item.price;
            }
        });
        return ntm*100;
      }
        }
}
</script>
<style lang="">
    
</style>